<template>
    <div class="system_msg_wrap">
        <div class="system_head">
            <div class="system_tab_left">
            <div
                @click="msgTabClick(0)"
                :class="{ active: systemTab == 0 }"
            >
                群消息
            </div>
            <div
                @click="msgTabClick(1)"
                :class="{ active: systemTab == 1 }"
            >
                审核通知
            </div>
            </div>
            <div class="system_h_right">
            <!-- <span class="s_delete"></span> -->
            </div>
        </div>
        <div class="system_content">
            <div class="group_message" v-show="systemTab == 0">
            <div
                class="group_msg_item"
                v-for="(item, index) in groupNews"
                :key="'gn_i' + index"
                @click="newsInfo(item)"
            >
                <div class="g_item_l">
                <div class="g_person_wrap">
                    <img
                    :src="
                        !$isNull(item.head) ? (`${$store.state.headPathUrl}${item.applyid}${item.head}.PNG`) : `static/image/home/person_${item.gender}.png`"
                        :onerror="defaultImg"
                    />
                </div>
                <div class="g_msg_info">
                    <div class="g_m_name">{{ item.userName }}
                    <span v-show="!$isNull(item.department)">({{ item.department }})</span>
                    </div>
                    <div class="g_m_info">
                    <div v-if="item.type == 1">
                        申请加入<span>{{
                        item.groupName ? item.groupName : "群聊"
                        }}</span>
                    </div>
                    </div>
                </div>
                </div>
                <div class="g_item_r">
                <div
                    v-if="item.agreest != 0 && item.agreest != 1"
                    class="g_refuse"
                    @click.stop.prevent="addMemberOption(1, item)"
                >
                    拒绝
                </div>
                <div
                    v-if="item.agreest != 0 && item.agreest != 1"
                    class="g_adopt"
                    @click.stop.prevent="addMemberOption(0, item)"
                >
                    通过
                </div>
                <div
                    style="
                    color: #40b75c;
                    width: 60px;
                    height: 28px;
                    line-height: 28px;
                    text-align: center;
                    background: inherit;
                    "
                    v-if="item.agreest == 0"
                >
                    已通过
                </div>
                <div
                    style="
                    color: #999999;
                    width: 60px;
                    height: 28px;
                    line-height: 28px;
                    text-align: center;
                    background: inherit;
                    "
                    v-else-if="item.agreest == 1"
                >
                    已拒绝
                </div>
                </div>
            </div>
            </div>
            <div class="audit_notice" v-show="systemTab == 1">
            <div
                class="notice_item"
                v-for="(item, index) in auditNotice"
                :key="'notice' + index"
            >
                <div class="notice_time">{{ item.time | timeFormat }}</div>
                <div class="notice_msg">
                <div v-if="item.type == 1">
                    <span>{{ item.groupName }}</span
                    >管理员({{ item.sendName }}){{
                    item.opinion == "0" ? "已同意" : "谢绝了"
                    }}您加群请求
                </div>
                </div>
            </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name:'systemNotice',
    props:{
        groupNews:{
            type: Array,
            default: () => {
                return []
            }
        },
        auditNotice:{
            type: Array,
            default: () => {
                return []
            }
        }
    },
    data(){
        return{
            systemTab:0,
            defaultImg:
                'this.src="static/image/home/person_1.png"',             
        }
    },
    methods:{
        msgTabClick(index) {
            this.systemTab = index;
        },
        addMemberOption(option, item){
            this.$emit('addMemberOption',option, item)
        },
        newsInfo(item){
            this.$emit('newsInfo',item)
        }        
    },
    mounted(){
        console.log('通知列表',this.auditNotice)
        console.log('群通知列表',this.groupNews)
    }
}
</script>